package com.qdu.service.impl;

import com.qdu.entity.Complete;
import com.qdu.entity.Photo;
import com.qdu.mapper.CompleteMapper;
import com.qdu.mapper.PhotoMapper;
import com.qdu.service.IPhotoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ellery2018
 * @since 2022-03-09
 */
@Service
@RequiredArgsConstructor
public class PhotoServiceImpl extends ServiceImpl<PhotoMapper, Photo> implements IPhotoService {

    private final PhotoMapper photoMapper;

    private final CompleteServiceImpl completeService;


    @Override
    public int insertphoto(String mypose, Integer userid, Integer routeid,String file_path) {
        Photo photo = new Photo();
        photo.setRouteId(routeid);
        photo.setUserId(userid);
        Date mydate = new Date();
        photo.setTime(mydate);
        photo.setPose(mypose);
        photo.setPictureUrl(file_path);
        photo.setId(1);
        photoMapper.insert(photo);
        completeService.photosign(userid, routeid);
        return 1;
    }
}
